package com.weigee.ktv.v.view;

import android.content.Context;
import android.support.annotation.ColorRes;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import com.l.d.app.library.view.CircleImageView;
import com.l.d.app.library.view.FocusedTextView;
import com.weigee.ktv.R;

/**
 * Created by 林德 on 2017/4/5 16:58.
 * <p/>
 */
public class WrapCircleTextButton extends RelativeLayout
{
    private CircleImageView m_civBackground;
    private FocusedTextView m_tvText;

    public WrapCircleTextButton(Context context)
    {
        this(context, null);
    }

    public WrapCircleTextButton(Context context, AttributeSet attrs)
    {
        this(context, attrs, 0);
    }

    public WrapCircleTextButton(Context context, AttributeSet attrs, int defStyleAttr)
    {
        super(context, attrs, defStyleAttr);
        this.init(context, attrs);
    }

    private void init(Context context, AttributeSet attrs)
    {
        ViewGroup view = (ViewGroup) LayoutInflater.from(context).inflate(R.layout.wrap_circle_tv, this, true);
        ViewGroup v2 = (ViewGroup) view.getChildAt(0);
        m_civBackground = (CircleImageView) v2.getChildAt(0);
        m_tvText = (FocusedTextView) v2.getChildAt(1);

        m_civBackground.setImageResource(R.color.colorAccent);
    }

    public void setButtonBackground(@ColorRes int colorResID)
    {
        if (m_civBackground == null) return;
        m_civBackground.setImageResource(colorResID);
    }

    public void setText(CharSequence text)
    {
        if (m_tvText == null) return;
        m_tvText.setText(text);
    }

    public void setTextSize(float size)
    {
        if (m_tvText == null) return;
        m_tvText.setTextSize(size);
    }
}
